CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(officeenv)

SET(CMAKE_CXX_FLAGS "-Wall")

SET(OGRE_STATIC TRUE)
SET(OGRE_HOME "${PROJECT_SOURCE_DIR}/ogre")

SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/ogre/lib/OGRE/cmake")

SET(OGRE_LIBRARY_FWK "")

FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(OGRE REQUIRED)
FIND_PACKAGE(X11 REQUIRED)

INCLUDE_DIRECTORIES(
    officeenv
    ${OGRE_INCLUDE_DIR}
    ${OGRE_INCLUDE_DIR}/RenderSystems/GL
    ${OIS_INCLUDE_DIR}
)

ADD_DEFINITIONS(-DINSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")

ADD_LIBRARY(officeenv SHARED 
    src/OfficeEnv.cpp 
    src/globals.cpp
    src/BaseOfficeScene.cpp 
    src/BSPOfficeScene.cpp 
    src/DotSceneLoader.cpp
    src/tinyxml/tinyxml.cpp
    src/tinyxml/tinystr.cpp
    src/tinyxml/tinyxmlparser.cpp
    src/tinyxml/tinyxmlerror.cpp
    src/DotSceneOfficeScene.cpp
)

FIND_LIBRARY(PLUGIN_BSPSCENEMANAGER NAMES Plugin_BSPSceneManagerStatic PATHS ${PROJECT_SOURCE_DIR}/ogre/lib/OGRE )
FIND_LIBRARY(PLUGIN_OCTREESCENEMANAGER NAMES Plugin_OctreeSceneManagerStatic PATHS ${PROJECT_SOURCE_DIR}/ogre/lib/OGRE )

TARGET_LINK_LIBRARIES(
    officeenv
    ${X11_LIBRARIES}
    ${OGRE_LIBRARIES}
    ${OPENGL_LIBRARIES}
    ${OGRE_RenderSystem_GL_LIBRARIES}
    ${PLUGIN_BSPSCENEMANAGER}
    ${PLUGIN_OCTREESCENEMANAGER}
)

INSTALL(TARGETS officeenv DESTINATION lib)
INSTALL(FILES src/OfficeEnv.h DESTINATION include/officeenv)
INSTALL(DIRECTORY resources/ DESTINATION share/officeenv)